/**
 * Created by Administrator on 2016/12/16.
 */

// 仅选择日期
$(".form-date").datetimepicker(
    {
        language:  "zh-CN",
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        minView: 2,
        forceParse: 0,
        format: "yyyy-mm-dd"
    });

$(function () {
    /*初始化*/
    init();
});

/*解析href*/
var str = location.search;
str = str.slice(1).split('&');
var json = {};
for (var i = 0; i < str.length; i++) {
    var a = str[i].split('=');
    json[a[0]] = a[1];
}
console.log(json);

function init(){
    $('#workTable').bootstrapTable({
        method : 'get',  //发送方式
        url : `http://192.168.59.3:8082/console/material/equipmentTypeDetailList?projectCode=${json.projectCode}&equipmentType=${json.equipmentType}`,
        onLoadSuccess:function(data){
            console.log(data);
            console.log("材料详情加载成功。。。");
            $('#addClick').click(function(){
                console.log(111);
                //获得当前工人userCode  teamId  projectCode
                layer.open({
                    type: 2,
                    maxmin: false,
                    shadeClose: true,
                    closeBtn: 1,
                    area : ['50%' , '80%'],
                    content:`materiel-detail-inner.html?projectCode=${json.projectCode}&teamId=${json.teamId}&userCode=${json.userCode}`,
                    title :　false
                });
            });
        }
    })
}
/*回调函数*/
function responseHandler(res) {

    var needData = {
        rows: res.data,
        total: res.total
    };

    return needData;
}
function totalFmt(val,row){
    return row.adjustmentnumber+row.number;
}
/*每页序号*/
/*function indexFmt(val,row,index){
    return index+1;
}*/
/*分页器*/
function workTableQuery(params){
    params["pageNum"] = (params.offset / params.limit) + 1;
    params.pageSize = params.limit;

    return params;
}
//*******************************/